<template>
  <div>
    <h2>最新商品</h2>
    <div>
       <ul>
         <li v-for="(item,index) in newsProductList" :key="index" @click="go(item.pid)">{{item.title}}</li>
       </ul>
    </div>
  </div>
</template>

<script lang='ts' setup>
import {ref} from 'vue'
import {useRouter} from 'vue-router'
const router=useRouter()
const newsProductList=ref([
  {
    pid:'n1001',
    title:'曲奇饼干',
    price:30
  },
  {
    pid:'n1002',
    title:'旺仔牛奶',
    price:20
  },
  {
    pid:'n1003',
    title:'AD钙奶',
    price:10
  }
])
const go=(arg:string)=>{
  router.push(`/product/newsProductDetail?id=${arg}`)
  
}
</script>

<style lang='scss' scoped>
</style>